﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WooCoo.Tools
{
    public class Check
    {
        public static T CheckArgumentNull<T>(T value, string parameterName) where T : class
        {
            if (value == null)
            {
                throw Error.Argument("EmptyString:",parameterName);
            }
            return value;
        }
        /// <summary>
        /// Checks the string value is not empty
        /// </summary>
        /// <param name="value">value to check </param>
        /// <param name="parameterName">parameterName of public function</param>
        /// <exception cref="System.ArgumentNullException">if value is null</exception>
        /// <exception cref="System.ArgumentException">if value is empty</exception>
        internal static void CheckArgumentNotEmpty(string value, string parameterName)
        {
            CheckArgumentNull(value, parameterName);
            if (0 == value.Length)
            {
                throw Error.Argument("EmptyString:", parameterName);
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="value"></param>
        /// <param name="parameterName"></param>
        [Obsolete]
        public static void CheckArgumentNullAndEmpty(string value, string parameterName)
        {
            Check.CheckArgumentNull<string>(value, parameterName);
            if (value.Length == 0)
            {
                throw Error.Argument("EmptyString", parameterName);
            }
        }
    }
}
